﻿

//域名地址
document.write('<script src="../../js/configPath.js"></script>');


//初始化页面数据，将获取的信息保存在对象params中
var params = {};
//获取用户验证
params.Tonken = localStorage.getItem('Tonken');
//获取用户信息
params.UserCode = localStorage.getItem('UserCode');
//获取用户浏览器内核
var userAgent = navigator.userAgent.toLowerCase(); 
jQuery.browser = { 
    version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1], 
    safari: /webkit/.test( userAgent ), 
    opera: /opera/.test( userAgent ), 
    msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), 
    mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) 
};
if($.browser.msie){
    params.BrowserID = 'msie';
}else if($.browser.safari){
    params.BrowserID = 'safari';
}else if($.browser.mozilla){
    params.BrowserID = 'mozilla';
}else if($.browser.opera){
    params.BrowserID = 'opera';
}else{
    params.BrowserID = 'unknow';
};
//获取用户来源
params.Source = '1';


//判断用户是否登录
params.Tonken === null&&(window.location.href = '../../login.html');
$(function(){

    //用户信息
    $("li[data-opt='user']>span").text(params.UserCode);
    
    //退出
    $("li[data-opt='sign_out']").on('click',function(){
        $.ajax({
            type: "post",
            url: mdmPath+"/MDM0001/MDM000106",
            data: {
                'Tonken': params.Tonken
            },
            dataType: "json",
            success: function(re){
                if(re.Status==200){
                    localStorage.removeItem('Tonken');
                    localStorage.removeItem('UserCode');
                    window.location.href = '../../login.html';
                }else{
                    alert(re.Message);
                }
            }
        });    
    });

});